import os
import sys
from typing import Optional


def app_root() -> str:
    base = getattr(sys, "_MEIPASS", None)
    if base and os.path.isdir(base):
        return base
    return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


def get_resource_path(relative_path: str) -> str:
    base = app_root()
    return os.path.join(base, relative_path)


